/**
 * 
 */
package com.wgo.precise.client.ui.view.util.celleditors;

import org.eclipse.jface.viewers.DialogCellEditor;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.dialogs.SelectionDialog;

import com.wgo.precise.client.ui.view.util.dialogs.TextInputDialog;


/**
 * @author petterei
 *
 * @version $Id: TextDialogCellEditor.java,v 1.1 2006-03-07 14:56:23 petterei Exp $
 */

public class TextDialogCellEditor extends DialogCellEditor {

	public TextDialogCellEditor(Composite parent, int style) {
		super(parent, style);
	}

	public TextDialogCellEditor(Composite parent) {
		super(parent);
	}

	/**
	 * @see org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(org.eclipse.swt.widgets.Control)
	 */
	@Override
	protected Object openDialogBox(Control cellEditorWindow) {
		Object origValue = getValue();
		TextInputDialog dialog = new TextInputDialog(cellEditorWindow.getShell(),"Text area", "Enter the text", (String)origValue) ;
		if (dialog.open() == SelectionDialog.OK && dialog.getValue().length() > 0){
			return dialog.getValue();
		}
		return origValue;
	}
}